<?phpnamespace app\common\validate;use think\Db;use think\Validate;class UserRole extends Validate{    protected $rule =   [        'role_name|角色名称'=>"require|checkName",        'menu_ids|权限'=>'require',    ];    /**     * 验证用户名和手机号码的唯一性     * @param $value     * @param $rule     * @param $data     * @return bool|string     */    public function checkName($value, $rule, $data){        $con = [            'role_name'=>$value        ];        if(isset($data['id']) &&!empty($data['id'])){            $con['id'] = ['<>',$data['id']];        }        $user = Db::name('user_role')->where($con)->find();        if($user){            return '角色名称已存在';        }        return true;    }}